package offer;

public class offer_0042 {
    public int maxSubArray(int[] nums) {
        int len=nums.length;
        int right=0;
        int max=nums[0];
        int current=0;
        for(;right<len;++right){
            current+=nums[right];
            max=Math.max(max,current);
            if(current<0){
                current=0;
            }
        }
        return max;
    }
}
